//
//  RequestLoadingPlugin.swift
//  ExtremeHealth
//
//  Created by Zhongkai Li 李忠凯 on 2018/9/29.
//  Copyright © 2018 GanDongKeJi. All rights reserved.
//

import Moya
import Alamofire
import enum Result.Result
import MBProgressHUD

class RequestLoadingPlugin: PluginType {
    func willSend(_ request: RequestType, target: TargetType) {
        MBProgressHUD.showAdded(to: UIWindow.key, animated: true)
    }

    func didReceive(_ result: Result<Response, MoyaError>, target: TargetType) {
        MBProgressHUD.hide(for: UIWindow.key, animated: true)
    }
}
